<?php

class DefaultController extends Controller
{
	public function actionIndex()
	{
		$this->render('index');
	}
	
	public function actionInstall()
	{
		if($this->module->install) {
			$path = Yii::getPathOfAlias($this->module->schemaPath);
			$script = $this->module->schemaScript;
			$file = $path . DIRECTORY_SEPARATOR . $script;
			if(is_readable($file) && !is_dir($file)) {
				$statements = file($file);
				$connection=Yii::app()->db;
				foreach($statements as $statement) {
					if(!empty($statement)) {
						$command=$connection->createCommand($statement);
						$command->execute();
					}
				}
			} else {
				throw new Exception('Could not locate installation script at  script at ' . $file);
			}
		}
		$this->render('install');
	}
	
	public function actionInstallVerify()
	{
		$this->render('installVerify');
	}
}